<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/13
 * Time: 14:44
 */

namespace app\common\library\ali\rabittmq;


class AliConfig
{

    public function getUser(){
        $accessKey = config('aliAmqp.accessKey');
        $resourceOwnerId = config('aliAmqp.resourceOwnerId');
        $t = '0:' . $resourceOwnerId . ':' . $accessKey;
        return base64_encode($t);
    }

    public function getPassword(){
        $ts = (int)(microtime(true)*1000);
        $accessSecret = config('aliAmqp.accessSecret');
        $value = utf8_encode($accessSecret);
        $key = utf8_encode((string)$ts);
        $sig = strtoupper(hash_hmac('sha1', $value, $key, FALSE));
        return base64_encode(utf8_encode($sig . ':' . $ts));
    }

}